package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsGoodsSpecificationMapper;
import com.qf.pojo.DtsGoodsSpecification;
import com.qf.service.DtsGoodsSpecificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version v1.0.0
 * @Description:
 * @author: 姜红凯
 * @date: 2022.02.23
 * @since 1.0
 */
@Service
public class DtsGoodsSpecificationServiceImpl implements DtsGoodsSpecificationService {

    @Autowired
    DtsGoodsSpecificationMapper specificationMapper;
    @Override
    public List<DtsGoodsSpecification> findByGoodsId(Integer id) {
        LambdaQueryWrapper<DtsGoodsSpecification> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsSpecification::getGoodsId,id);
        wrapper.eq(DtsGoodsSpecification::getDeleted,false);
        List<DtsGoodsSpecification> specifications = specificationMapper.selectList(wrapper);
        return specifications;
    }

    @Override
    public void deleteByGoodsId(Integer goodsId) {
        LambdaQueryWrapper<DtsGoodsSpecification> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsSpecification :: getGoodsId,goodsId);

        specificationMapper.delete(wrapper);
    }

    @Override
    public void insert(DtsGoodsSpecification specification) {
        specificationMapper.insert(specification);
    }
}
